#ifndef PROSPACE_H
#define PROSPACE_H
#include <iostream>

#include <cstring>
#include "CodeGenerator.h"


#include <iostream>
using namespace std;
class ProSpace{
friend ostream& operator<<(ostream& out, const ProSpace& space);
private:
	string* m_varname;
	int* m_varvalue;
	int m_comparevalue;
	float m_probability;
	int m_count;
	void clearBuffer(string varname);
	void clearBuffer(int index);

public:
	ProSpace();
	~ProSpace();
	ProSpace(const ProSpace& ps);
	ProSpace(string varname);
	ProSpace(string varname[], int varvalue[], float probability, int count);
	ProSpace(string varname, int varvalue, float probability, int count);
	void setValue(string varname, int value);
	void updateTmpValue(int value, int op);
	void updateTmpValue(string varname, int op);
	void updateByTmp(string varname);
	void updateByTmp(string from, string to);
	void updateCmpValue(int value);
	ProSpace getVarSpace(string varname);
	void setProbability(float);
	const float getProbability() const{
		return m_probability;
	}
	const int getHigh() const{
		return m_varvalue[0];
	}
	const int getLow() const{
		return m_varvalue[1];
	}
	void output(int index) const;
	int getIndex(string varname);
	const int getValue(int index) const;
	static ProSpace& jointSpace(ProSpace sp, ProSpace sp2);
	ProSpace operator+(const ProSpace&rhs);
	ProSpace& operator=(const ProSpace&rhs);
};
#endif